<template>
  <view>
    <view class="goods-list-box">
      
      <view class="goods-list-left">
       
          <radio :checked="goods.goods_state"  color="#C00000" v-if="showRadio" 
          @click="radioChangeHandler"
          
          /><text></text>
     
        <image :src="goods.goods_small_logo"  class="good_img"></image>
      </view>
      <view class="goods-list-right">
          <view class="good-price-name">
            {{goods.goods_name}}
          </view>
          <view class="goods-number-price">
            <view class="good-price">
              ￥{{goods.goods_price | tofixed}}
            </view>
            <view class="good-number">
              <uni-number-box :min="1" :value="goods.goods_count" v-if="showNum"
              @change="numberChangeHandler"
              ></uni-number-box>
            </view>
            
          </view>
      </view>
     
    </view>
  </view>
</template>

<script>
  export default {
      
    props:{
      goods:{
        type:Object,
        default:{}
      },
      showRadio:{
        type:Boolean,
        default:false
      },
      showNum:{
        type:Boolean,
        default:false
      }
    },
    name:"my-goods",
    data() {
        return {
          
        };
    },
    filters:{
        tofixed(num){
         return Number(num).toFixed(2);
          } 
      },
      methods:{
      radioChangeHandler(){
        this.$emit('radio-change',{
          goods_id:this.goods.goods_id,
          goods_state:!this.goods.goods_state 
       
        })
      },
    
      numberChangeHandler(val){
        console.log(val);
        this.$emit('numChange',{
          goods_id :this.goods.goods_id,
          goods_count : val*1
        })
      }
      }
    
  }
</script>

<style lang="scss" scoped>
.goods-list-box{
  margin-left: 5px;
  margin-right: 5px;
  margin-top: 15px;
  margin-bottom: 15px;
  display: flex;
  justify-content: space-around;
  border-bottom: 2px solid rosybrown;
  border-radius: 5px ;
  box-shadow: 0px 5px 2px #acacac;
  
  .goods-list-left{
    
    display: flex;
    margin-left: 25px;
    justify-content: space-between;
    align-items: center;
    .good_img{
      width: 80px;
      height: 80px;
     
    }
  }

    
  .goods-list-right{
    margin-right: 25px;
    margin-left: 25px;
    .good-price-name{
      font-size: 14px;
     
      
    }
    .good-price{
      font-size: 20px;
      color: orangered;
    }
    .goods-number-price{
      display: flex;
      margin-bottom: 10px;  
      justify-content: space-between;
    }
  
  }
 
}
</style>